home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
asmutil
/
asm_n_z.zip
/
SETUP2.ASM
< prev
next >
Wrap
Assembly Source File
|
1989-03-06
|
42KB
|
1,355 lines
;=============================================================================
; SETUP 2.0 allows text and control codes to be sent directly to a printer
; from the command line or from within a popup menu window. Syntax is:
;
; SETUP2 [d:][path][filename] | [/C codes] | [/U]
;
; where filename = Name of PMF file
; /C = Codes to be sent from the command line
; /U = Uninstall the program
;=============================================================================
code segment para public 'code'
assume cs:code
org 100h
begin: jmp initialize
program db "SETUP 2.0 "
copyright db "(c) 1989 Ziff Communications Co.",13,10
author db "PC Magazine ",254," Jeff Prosise",13,10
hotkey db "Hotkey is Ctrl-Rt/Shift",13,10,"$",1Ah
videocols db ? ;number of columns displayed
videopage db ? ;active video page
videoseg dw ? ;video segment
videostart dw ? ;starting video address
videocursormode dw ? ;cursor description
videocursorpos dw ? ;BIOS cursor position
pname db 26 dup (20h) ;menu window title
lpt_number dw 0 ;LPT port number
status db 0 ;program status flag
int9h dd ? ;interrupt 9h vector
window_start label word
window_x db ? ;starting window column
window_y db 1 ;starting window row
window_end dw ? ;lower right window corner
border_attr db ? ;border color
menu_attr db ? ;window color
hilite_attr db ? ;highlight color
cursor_def dw ? ;default cursor definition
index db 0 ;menu selection index
ten db 10 ;base 10 divisor
linecount dw 0 ;number of menu lines
pagecount db 1 ;number of menu pages
menupage db 0 ;current menu page
code_table dw offset menu_table ;address of control code table
end_offset dw offset menu_table ;ending program address
;=============================================================================
; KBINT receives control when an interrupt 9 is generated.
;=============================================================================
kbint proc far
pushf ;call BIOS keyboard routine
call int9h
sti ;enable interrupts
push ax
mov ah,2 ;get shift key status
int 16h
and al,0Fh ;mask off upper four bits
cmp al,5 ;was the hotkey combo pressed?
pop ax
jne kb_exit ;no, then exit
cmp status,0 ;check program status
jne kb_exit ;exit if it's already up
call main ;pop up the window
kb_exit: iret ;exit
kbint endp
;=============================================================================
; MAIN is the main body of the program.
;=============================================================================
main proc near
mov status,1 ;set program status flag
push ax ;save all registers
push bx
push cx
push dx
push bp
push si
push di
push ds
push es
mov ah,15 ;abort if the current video
int 10h ; mode is not a text mode
cmp al,7
je main1
cmp al,4
jb main1
;
;Restore register values and return to caller.
;
main_exit: pop es ;restore registers
pop ds
pop di
pop si
pop bp
pop dx
pop cx
pop bx
pop ax
mov status,0 ;clear program status flag
ret
;
;Save video parameters and read the cursor address from the CRT controller.
;
main1: push cs ;establish DS addressability
pop ds ; by pointing it to the
assume ds:code ; code segment
cld ;clear DF for string ops
mov videocols,ah ;save columns displayed
mov videopage,bh ;save active video page
mov ah,3 ;get cursor information
int 10h
mov videocursormode,cx ;save cursor mode
mov videocursorpos,dx ;save cursor position
mov ax,40h ;point ES to the BIOS
mov es,ax ; data area
mov dx,es:[4Eh] ;save video start address
mov videostart,dx
;
;Define monochrome or color video attributes.
;
test byte ptr es:[63h],40h ;branch if this is
jnz colorvideo ; a color system
mov videoseg,0B000h ;monochrome attributes
mov border_attr,70h
mov menu_attr,07h
mov hilite_attr,70h
mov cursor_def,0C0Dh
jmp short vsave
colorvideo: mov videoseg,0B800h ;color attributes
mov border_attr,70h
mov menu_attr,4Fh
mov hilite_attr,70h
mov cursor_def,0607h
;
;Save video memory underlying the menu window, then open the window.
;
vsave: mov ah,1 ;hide the cursor
mov ch,20h
int 10h
mov cl,videocols ;determine window position
sub cl,32
mov window_x,cl ;save starting column number
mov ch,window_y
mov dx,cx
add dx,101Dh ;save coordinates of lower
mov window_end,dx ; right window corner
push cs ;point ES:DI to screen buffer
pop es
mov di,offset screen_buffer
mov ax,offset udr_vio2mem ;call SCANREGION routine to
mov cx,window_start ; buffer the contents of
mov dx,window_end ; video memory
call scanregion
call openwindow ;open printer menu window
mov al,hilite_attr ;draw menu selection bar
call drawmenubar
;
;Monitor the keyboard for keystrokes and act upon the ones received.
;
keyloop: mov ah,0 ;get a keystroke
int 16h
or al,al ;branch on extended keycodes
jz functionkey
;
;Output control codes if ENTER was pressed.
;
cmp al,13 ;check for ENTER keycode
jne escape
call outputlpt ;output indexed control codes
jmp keyloop ;return to input loop
;
;Close the window and exit if ESC was pressed.
;
escape: cmp al,27 ;check for ESC keycode
jne slash
jmp close ;jump to exit routines
;
;Jump down to the input line if the slash key was pressed.
;
slash: cmp al,"/" ;check for slash character
jne keyloop ;ignore anything else
mov al,menu_attr ;blank the menu bar
call drawmenubar
call scanline ;read input and send to LPT
mov al,hilite_attr ;redraw the menu bar
call drawmenubar
jmp keyloop ;loop back for more
;
;Send the corresponding control codes if a function key was pressed.
;
functionkey: cmp ah,59 ;determine whether or not a
jb keyloop ; function key was pressed
cmp ah,68
ja up_arrow
push ax ;save extended keycode
mov al,menu_attr ;erase the menu bar
call drawmenubar
pop ax ;recover keycode
sub ah,59 ;calculate new INDEX value
mov index,ah
mov al,hilite_attr ;draw new menu bar
call drawmenubar
call outputlpt ;output corresponding codes
jmp keyloop ;return to input loop
;
;Move the menu bar up one line if up-arrow was pressed.
;
up_arrow: cmp ah,72 ;check for up-arrow
jne dn_arrow
mov al,menu_attr ;erase the menu bar
call drawmenubar
dec index ;decrement INDEX and wrap
jns newbar ; if necessary
mov index,9
newbar: mov al,hilite_attr ;redraw the menu bar
call drawmenubar
jmp keyloop ;return to input loop
;
;Move the menu bar down one line if down-arrow was pressed.
;
dn_arrow: cmp ah,80 ;check for down-arrow
jne pgup
mov al,menu_attr ;erase the menu bar
call drawmenubar
inc index ;increment INDEX and wrap
cmp index,10 ; around if necessary
jne newbar ;jump to finish up
mov index,0
jmp newbar
;
;Flip to the preceding menu page if PgUp was pressed.
;
pgup: cmp ah,73 ;check for PgUp
jne pgdn
cmp pagecount,1 ;ignore if there is only
je retkey ; one menu
dec menupage ;set MENUPAGE to previous
jns newpage ; page and wrap around
mov al,pagecount ; if necessary
dec al
mov menupage,al
newpage: call writemenu ;write text of page to memory
mov al,hilite_attr ;redraw the menu bar
call drawmenubar
retkey: jmp keyloop ;return to input loop
;
;Flip to the next page if PgDn was pressed.
;
pgdn: cmp ah,81 ;check for PgDn
jne retkey
cmp pagecount,1 ;ignore if there is only
je retkey ; one menu
inc menupage ;adjust MENUPAGE
mov al,pagecount
cmp menupage,al
jne newpage ;jump to finish up
mov menupage,0
jmp newpage
;
;Close the menu window.
;
close: mov si,offset screen_buffer ;point SI to buffer
mov ax,offset udr_mem2vio ;call SCANREGION routine to
mov cx,window_start ; restore the contents of
mov dx,window_end ; video memory
call scanregion
;
;Restore the cursor mode and position, then